package com.henu.rescue.service.impl;

import com.henu.rescue.entity.Station;
import com.henu.rescue.entity.Telephone;
import com.henu.rescue.entity.VO.TelVO;
import com.henu.rescue.mapper.TelMapper;
import com.henu.rescue.service.TelService;
import com.henu.rescue.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TelServiceImpl implements TelService {

    @Autowired
    private TelMapper telMapper;

    @Override
    public Integer addTel(Telephone telephone) {
        return telMapper.addTel(telephone);
    }

    @Override
    public Integer delTel(Integer telId) {
        return telMapper.delTel(telId);
    }

    @Override
    public Integer updateTel(Telephone telephone) {
        return telMapper.updateTel(telephone);
    }

    @Override
    public Page<TelVO> selectTelInfoByPage(Page<TelVO> page) {
        List<TelVO> telList = telMapper.selectTelInfoByPage(page);
        page.setList(telList);
        //查询总数
        int totalCount =telMapper.getCountByPage(page);
        page.setTotalCount(totalCount);
        return page;
    }

    @Override
    public Integer selectTel(String telNumber, Integer telType, Integer hostId) {
        return telMapper.selectTel(telNumber,telType,hostId);
    }

    @Override
    public Integer delTelFromOrg(Integer telType, Integer hostId) {
        return telMapper.delTelFromOrg(telType,hostId);
    }

    @Override
    public Telephone selectById(Integer telId) {
        return telMapper.selectById(telId);
    }

    //根据type和hostId查询
    @Override
    public Telephone selectByTypeHostId(Integer telType, Integer hostId) {
        return telMapper.selectByTypeHostId(telType,hostId);
    }
}
